﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Cache;
using System.Text;
using System.Threading.Tasks;
using Kugar.Core.BaseStruct;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RabbitMQ.Client;

namespace Kugar.Tool.RemoteRPC.ClientTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var connFactory = new ConnectionFactory()
            {
                HostName = "203.195.191.64",
                Port = 5672,
                VirtualHost = "developtest",
                UserName = "ylcoretest",
                Password = "123456",
                AutomaticRecoveryEnabled = true,
                RequestedHeartbeat = 10,
                NetworkRecoveryInterval = new TimeSpan(0, 0, 10)
            };

            var conn = connFactory.CreateConnection();
            conn.AutoClose = false;


            var clientID = RandomEx.Next();

            Console.WriteLine(clientID);

            var rpc=new RemoteRPC(conn,"RPCClientTest"+ clientID);



            for (int i = 0; i < 5; i++)
            {
                new Task(() =>
                {
                    var result = rpc.Call("SendSMS", new JObject()
                    {
                        ["Arg1"] = clientID.ToString(),

                    });

                    Console.WriteLine(result.ToString(Formatting.None));
                }).Start();


            }

            Console.ReadLine();
        }
    }
}
